package com.huanzhidadi.java8inaction.chapter7.responsibilitychain;

import java.util.function.Function;
import java.util.function.UnaryOperator;

/**
 * Lambda表达式版的责任链模式
 */
public class Client2 {

    public static void main(String[] args) {

        UnaryOperator<String> headerProcessing = text -> "From Java8 in Action: " + text;
        UnaryOperator<String> checkerProcessing = text -> text.replaceAll("work", "world");

        Function<String, String> pipeline = headerProcessing.andThen(checkerProcessing);

        String result = pipeline.apply("Hello work!!");
        System.out.println(result);
    }

}
